from selenium import webdriver
from time import sleep
# 导入动作链对应的类
from selenium.webdriver import ActionChains

# 实例化浏览器对象
bro = webdriver.Chrome(executable_path='./chromedriver')

bro.get('https://www.runoob.com/try/try.php?filename=jqueryui-api-droppable')

# 如果定位的标签是存在于iframe标签中的必须通过如下操作进行标签定位
bro.switch_to.frame('iframeResult')  # 切换浏览器标签定位的作用域
div = bro.find_element_by_id('draggable')

# 动作链
# 实例化动作链
action = ActionChains(bro)
# 点击并长按指定的标签
action.click_and_hold(div)
for i in range(5):
    # 做移动偏移动作（x,y）多少像素，perform（）表示立即执行动作链
    action.move_by_offset(17,0).perform()
    sleep(0.3)

# 完成后释放动作链
action.release()

bro.quit()


















